	package com.ezjie.baselib.spfs;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;





import com.ezjie.baselib.application.MyApplication;

import android.R.integer;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * SharedPreferences的工具类
 * 
 * @author renyangyang
 * 
 */
public class SharedPrefHelper {
	/**
	 * SharedPreferences的名字?
	 */
	private static final String SP_FILE_NAME = "project";
	private static SharedPrefHelper sharedPrefHelper = null;
	private static SharedPreferences sharedPreferences;
	private static final String LOGIN_KEY = "login_key";
	private static final String LOGIN_UID = "uid";
	private static final String ISFIRSTIN_TAG = "isFirstIn";
	private static final String IS_LOGIN = "isLogin";// 是否登录
	public static synchronized SharedPrefHelper getInstance() {
		if (null == sharedPrefHelper) {
			sharedPrefHelper = new SharedPrefHelper();
		}
		return sharedPrefHelper;
	}

	private SharedPrefHelper() {
		sharedPreferences = MyApplication.myApplication.getSharedPreferences(
				 SP_FILE_NAME, Context.MODE_PRIVATE);
	}

	/**
	 * 是否为第一次进入
	 * 
	 * @param flag
	 */
	public void setFirstIn(boolean flag) {
		sharedPreferences.edit().putBoolean(ISFIRSTIN_TAG, flag).commit();
	}

	public boolean isFirstIn() {
		return sharedPreferences.getBoolean(ISFIRSTIN_TAG, true);
	}
	
	/**
	 * 是否登录
	 * 
	 * @param flag
	 */
	public void setIsLogin(boolean flag) {
		sharedPreferences.edit().putBoolean(IS_LOGIN, flag).commit();
	}

	public boolean isLogin() {
		return sharedPreferences.getBoolean(IS_LOGIN, false);
	}
	/**
	 * 保存一组uid 和 login_key
	 * 
	 */
	
	public void setLoginKey(String Login_key){
		sharedPreferences.edit().putString(LOGIN_KEY, Login_key);
	}
	
	public String isLoginkey(){
		return sharedPreferences.getString(LOGIN_KEY, null);
		
	}
	
	public void setLoginUid(String uid){
		sharedPreferences.edit().putString(LOGIN_UID, uid);
	}
	
	public String isLoginUid(){
		return sharedPreferences.getString(LOGIN_UID, null);
		
	}
	

}
